<jsp:directive.page contentType="text/html;charset=UTF-8" />
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="../../WEB-INF/c.tld" prefix="c" %>

<div class="main">
	<div class="container">
		<h2><bean:message key="livraison.list.mainTitle" /></h2>	
		 <c:if test="${success != null }">
			<div class="alert alert-success">
				<bean:message key="${success }" />
    		</div>
		</c:if>
		<c:if test="${error != null}">
			<div class="alert alert-error">
				<bean:message key="${error }" />
    		</div>
		</c:if>
			<table class="table table-striped">
				<thead>
					<tr>
						<th><bean:message key="livraison.libelle" /></th>
						<th><bean:message key="livraison.coutNormalClient" /></th>
						<th><bean:message key="livraison.coutSuperClient" /></th>
						<th><bean:message key="general.action" /></th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${listModeLivraison}" var="modeLivraison" >					
						<tr>
							<td>${modeLivraison.libelle }</td>
							<td><input type="text" id="coutClientNormal[${modeLivraison.idMode }]" size="16" maxlength="16" value="${modeLivraison.coutClientClassique }"/></td>
							<td><input type="text" id="coutSuperClient[${modeLivraison.idMode }]" size="16" maxlength="16" value="${modeLivraison.coutSuperClient }"/></td>
							<td>
								<div class="listAction">
									<div class="icon-refresh submitLivraison" title="Save" id="${modeLivraison.idMode }"></div></button>
								</div>
							</td>
						</tr>			
					</c:forEach>
				</tbody>				
	    	</table>
	    	<html:form action="/mode-livraison-post" method="post" styleId="formLivraison">
				<html:hidden property="idMode" styleId="idMode" value=""/>
				<html:hidden property="coutClientNormal" value="" styleId="coutClientNormal" />
				<html:hidden property="coutSuperClient" value="" styleId="coutSuperClient" />
	    	</html:form>
    	<div class="linkCenter"><a class="btn btn-primary" href="<%= request.getContextPath() %>/list-relai.do"><bean:message key="livraison.RelaiAccess" /></a></div>
	</div>
</div>

<script type="text/javascript">

$$('.submitLivraison').invoke('observe', 'click', function(evt){
	var id = this.id;
	$('idMode').setValue(id);
	$('coutClientNormal').setValue($('coutClientNormal['+id+']').getValue());
	$('coutSuperClient').setValue($('coutSuperClient['+id+']').getValue());
	$('formLivraison').submit();
});
</script>